package hhh.app.presenter.model.productlist;

import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;

import butterknife.BindView;
import hhh.app.R;
import hhh.app.presenter.App;
import hhh.app.presenter.di.component.ProductComponent;
import hhh.app.presenter.ui.base.BaseActivity;

public class ProductListActivity extends BaseActivity {
    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.navigation_view)
    NavigationView navigationView;

    private ProductListFragment productListFragment;
//    private ProductDetailFragment productDetailFragment;

//    private ProductComponent productComponent;

    @Override
    protected void init() {
        setSupportActionBar(mToolbar);
        navigationView.setCheckedItem(R.id.nav_list);
        navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(MenuItem item) {
                return true;
            }
        });

//        productComponent = DaggerProductComponent.builder()
//                .appComponent(getAppComponent())
//                .productModule(new ProductModule())
//                .build();
        productListFragment = new ProductListFragment();
//        productDetailFragment=new ProductDetailFragment();

//        addFragment(R.id.fragment_container, productListFragment);
        switchFragment(productListFragment);
    }

    public void switchFragment(Fragment fragment){
        addFragment(R.id.fragment_container,fragment);
    }

    @Override
    protected int getLayoutResId() {
//        return R.layout.activity_productlist;
        return R.layout.drawlayout_list;
    }

    public ProductComponent getComponent() {
        return ((App)getApplication()).getProductComponent();
    }

}
